//
//  HR_Touch_CustomController.m
//  3DTouch
//
//  Created by duanhuifen on 2017/7/20.
//  Copyright © 2017年 huifen. All rights reserved.
//

#import "HR_Touch_CustomController.h"
#import "HR_Touch_CustomCell.h"

//static NSString *const CustomCellId = @"HR_Touch_CustomCell";

@interface HR_Touch_CustomController ()<
    UITableViewDelegate,
    UITableViewDataSource
>
@property (strong, nonatomic) UITableView *myTableView;
@property (nonatomic,assign) NSInteger actionIndex;

@end

@implementation HR_Touch_CustomController

- (void)viewDidLoad {
    [super viewDidLoad];
    UITableView *myTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.myTableView = myTableView;
    [self.view addSubview:myTableView];
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;

//    [self.myTableView registerNib:[UINib nibWithNibName:@"HR_Touch_CustomCell" bundle:nil] forCellReuseIdentifier:CustomCellId];
    
}

//- (NSArray<id<UIPreviewActionItem>> *)previewActionItems {
//    
////    // setup a list of preview actions
////    UIPreviewAction *action1 = [UIPreviewAction actionWithTitle:@"Aciton1"
////                                                          style:UIPreviewActionStyleDefault
////                                                        handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
////                                                            NSLog(@"Aciton1");
////                                                        }];
////    
////    UIPreviewAction *action2 = [UIPreviewAction actionWithTitle:@"Aciton2"
////                                                          style:UIPreviewActionStyleDefault
////                                                        handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
////                                                            NSLog(@"Aciton2");
////                                                        }];
////    
////    UIPreviewAction *action3 = [UIPreviewAction actionWithTitle:@"Aciton3"
////                                                          style:UIPreviewActionStyleDefault
////                                                        handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
////                                                            NSLog(@"Aciton3");
////                                                        }];
////    
////    NSArray *actions = @[action1,action2,action3];
//    
//    // and return them (return the array of actions instead to see all items ungrouped)
////    return actions;
//  return  [self creatPreviewActionWithTitle:self.preViewActionArr];
//}

//- (NSMutableArray *)creatPreviewActionWithTitle:(NSArray *)titleArr{
//    __weak typeof(self)weakSelf = self;
//    NSMutableArray * preViewActionArr = [NSMutableArray array];
//    
//    for (NSString * titleStr in titleArr) {
//        UIPreviewAction *action = [UIPreviewAction actionWithTitle:titleStr
//                                                              style:UIPreviewActionStyleDefault
//                                                            handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
////                                                                [weakSelf previewActionWithTitle:titleStr];
//                                                            }];
//        [preViewActionArr addObject:action];
//    }
//    return preViewActionArr;
//}

//- (void)previewActionWithTitle:(NSString *)title{
//    [self.preViewActionArr enumerateObjectsUsingBlock:^(NSString *_Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
//        if ([obj isEqualToString:title]) {
//            self.actionIndex = idx;
//            [self previewActionClick];
//        }
//    }];
//}

//previewAction的点击
//- (void)previewActionClick{
//    NSLog(@"%ld",(long)self.actionIndex);
//}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    HR_Touch_CustomCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if(!cell)
    {
        cell=[[HR_Touch_CustomCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }
    
    return cell;
//    HR_Touch_CustomCell * customCell = [tableView dequeueReusableCellWithIdentifier:CustomCellId];
//    return  customCell;
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 35;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
